package com.neuedu.corejava.ch10;

import java.util.Deque;
import java.util.LinkedList;

public class LinkedListClass {

	public static void main(String[] args) {
		//LinkedList类实现了多种数据结构
		//实现了（双端）链表结构，队列
		
		//队列结构（先进先出，后进后出）
		//LinkedList<Computer> linkedList = new LinkedList<>();
		//双端队列
		Deque<Computer> linkedList = new LinkedList<>();
		
		linkedList.addLast(new Computer("HP",5000));
		linkedList.addLast(new Computer("MP",4000));
		linkedList.addLast(new Computer("CP",3000));
		linkedList.addLast(new Computer("OP",6000));
		linkedList.addLast(new Computer("EP",4000));
		linkedList.addLast(new Computer("AP",3000));
		linkedList.addLast(new Computer("DP",5000));
		
		Computer computer = null;
		while ((computer=linkedList.pollFirst())!=null) {
			System.out.println(computer);	
		}
		
		System.out.println("--------------------------");
		linkedList = new LinkedList<>();
		linkedList.addFirst(new Computer("HP",5000));
		linkedList.addFirst(new Computer("MP",4000));
		linkedList.addFirst(new Computer("CP",3000));
		linkedList.addFirst(new Computer("OP",6000));
		linkedList.addFirst(new Computer("EP",4000));
		linkedList.addFirst(new Computer("AP",3000));
		linkedList.addFirst(new Computer("DP",5000));
		
		computer = null;
		while ((computer=linkedList.pollLast())!=null) {
			System.out.println(computer);	
		}

	}

}
